export default function(tHeader, filterVal, excelName, tableData = 'tableData') {
  return {
    methods: {
      m_exportData() {
        import('@/vendor/Export2Excel').then(excel => {
          const data = this.m_formatJson(filterVal, this[tableData])
          excel.export_json_to_excel({
            header: tHeader,
            data,
            filename: excelName || this.$options.name,
            autoWidth: true,
            bookType: 'xlsx'
          })
        })
      },
      m_formatJson(filterVal, jsonData) {
        return jsonData.map(v => filterVal.map(j => { return v[j] }))
      }
    }
  }
}
